<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="/static/css/font.css">
    <link rel="stylesheet" href="/static/css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="/static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->


      <!-- 增加 sweetalert -->
      <link rel="stylesheet" href="/static/sweetalert/sweetalert.css">
      <script src="/static/sweetalert/ions_alert.js"></script>
      <script src="/static/sweetalert/sweetalert.min.js"></script>

  </head>
  <body>
    <div class="x-body">
        <form class="layui-form">
          <div class="layui-form-item">
              <label for="L_email" class="layui-form-label">
                  <span class="x-red">*</span>事由
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="reason" name="reason"  lay-verify="required"
                  autocomplete="off" class="layui-input" value="{{ .cars_apply.Reason }}" disabled style="cursor: not-allowed">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="L_username" class="layui-form-label">
                  <span class="x-red">*</span>目的地
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="destination" name="destination"  lay-verify="required"
                         autocomplete="off" class="layui-input" value="{{ .cars_apply.Destination }}" disabled style="cursor: not-allowed"> <!--无法修改样式-->
              </div>
          </div>
            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label">
                    <span class="x-red">*</span>审核状态
                </label>
                <div class="layui-input-inline">
                <!--审核状态判断-->
                    {{ if eq .cars_apply.AuditStatus 1 3 }}
                        <input type="radio" name="audit_status" class="layui-input" title="同意" checked value="1">
                        <input type="radio" name="audit_status" class="layui-input" title="不同意" value="2" >
                    {{ else if .cars_apply.AuditStatus 2 }}
                        <input type="radio" name="audit_status" class="layui-input" title="同意" value="1">
                        <input type="radio" name="audit_status" class="layui-input" title="不同意" checked value="2">
                    {{ end }}

                </div>
            </div>
            <!--增加class 审核意见-->
            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label">
                    <span class="x-red">*</span>审核意见
                </label>
                <div class="layui-input-inline">
                    <input class="layui-input" placeholder="审核意见" id="option" value="{{ .cars_apply.AuditOption }}" >
                </div>
          <div class="layui-form-item">
              <label for="L_repass" class="layui-form-label">
              </label>
              <input type="hidden" id="id" value="{{ .cars_apply.Id }}" > <!--注意修改id-->
              <button  class="layui-btn" lay-filter="add" lay-submit type="button"> <!--添加button-->
                  提交
              </button>
          </div>
      </form>
    </div>
        <script>
        /*定义ajax*/
/*        $(function  () {
            /!* 时间插件 *!/
            layui.use('laydate', function(){
                var laydate = layui.laydate;

                //执行一个laydate实例
                laydate.render({
                    elem: '#return_date', //指定元素
                    type: 'date'
                });
            });*/
            /*增加layui*/
            layui.use('form', function () {
                var form = layui.form;
                //监听提交
                form.on('submit(add)', function (data) {
                    var option = document.getElementById("option").value;
                    var id = document.getElementById("id").value;
                    var audit_status = $("input[name='audit_status']:checked").val();

                    /* ajax调用 */
                    $.ajax({
                        url : "{{ urlfor `CarsApplyController.DoAuditApply` }}",
                        type : "POST",
                        data : {
                            "option" : option,
                            "id": id,
                            "audit_status" :audit_status
                        },
                        success:function (data){
                            /* 添加后端显示数据 */
                            var code = data["code"]
                            if (code == 200) {
                                ions_alert.alertSuccessToast(data["msg"])
                                /* 定时器 */  /* 重定向 */
                                setTimeout(reload_list,2000)
                            } else  {
                                ions_alert.alertErrorToast(data["msg"])
                            }
                        },
                        fail:function (data) {
                            alert(data)
                        }
                    });

                    /* 重定向 */
                    function reload_list () {
                        /* 获得frame索引 */
                        var index = parent.layer.getFrameIndex(window.name);
                        /* 关闭当前frame,关闭弹出小窗口 */
                        parent.layer.close(index);
                        window.location.href = "{{ urlfor `CarsApplyController.Get` }}"
                    }
                });
            })
    </script>
  </body>
</html>